<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>信息管理系统界面</title>
    <link href="../css/admin/style.css" rel="stylesheet" type="text/css" />

    <style type="text/css">
        *{
            margin: 0px;
            padding: 0px;
        }
    </style>
    <script src="../js/jquery-1.8.3.min.js" type="text/javascript"></script >
    <script type="text/javascript">
        $(function (){
            var account = window.sessionStorage.getItem("account");
            var id = window.sessionStorage.getItem("id");
            var type = window.sessionStorage.getItem("type");
            var newFileName = window.sessionStorage.getItem("newFileName");
            console.log(newFileName)
            if(account==null){
                location.replace("login.html");
                return;
            }
            $("#accountId").html(account);
            if (newFileName != "null"){
                var imgsrc = "http://localhost:8080/userImg/"+account+"/"+newFileName;
                document.getElementById("imgId").innerHTML = "<img src = '"+imgsrc+"' width='30' height='30'/>"
            }
            $.get("../loginadmin/findMenu",{id:id,type:type},function (data){
                console.log(data);
                if (data.code == 202 ||data.code == 500){
                    alert(data.msg);
                }else {
                    var str = "";
                    for ( i = 0; i < data.data.length; i++) {
                        str+=" <li><cite></cite>\n";
                        str+="<a href='"+data.data[i].url+"' target=\"workspace\">"+data.data[i].name+"</a>\n";
                        str+="</li>";
                    }
                    $("#menuId").html(str);
                }
            })

        })

        //安全退出
        function exit(){
            if(confirm("您确定要退出吗?")){
                //删除前端浏览器存储的用户信息
                window.sessionStorage.removeItem("account");
                window.sessionStorage.removeItem("id");
                window.sessionStorage.removeItem("type");
                window.sessionStorage.removeItem("newFileName");
                 $.get("../loginadmin/loginOut",function (res){
                     console.log(res);
                     location.replace("login.html");
                 })
            }
        }

    </script>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="0" width="100%" height="100%">
    <tr style="background:url(../img/admin/topbg.gif) repeat-x;">
        <td colspan="2">
            <div class="topleft">
                <img src="../img/admin/logo.png" title="系统首页" />
            </div>

            <div class="topright">
                <ul>
                    <li id="updatepwd"><a href="update.html" target="rightFrame">修改密码</a></li>
                    <li><a href="javaScript:void(0)" onclick="exit()">退出</a></li>
                    <li id="imgId"><a href="upload.html" target="rightFrame">上传头像</a></li>
                </ul>
                <div class="user">
                    <span id="accountId"> </span>
                </div>
            </div>
        </td>
    </tr>
    <tr>
        <td width="187" valign="top"  height="100%"  style="background:#f0f9fd;">
            <div class="lefttop"><span></span>操作菜单</div>
            <dl class="leftmenu">
                <dd>
                    <div class="title">
                        <span><img src="../img/admin/leftico01.png"/></span>
                        <a href="javaScript:void(0)">管理信息</a>
                    </div>
                    <ul class="menuson" id="menuId">

                    </ul>
                </dd>
            </dl>
        </td>
        <td>
            <iframe name="workspace" src="" width="100%" height="600"></iframe>
        </td>
    </tr>
</table>
</body>
</html>
